{include file="common/_header-css"}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="answers[1]" class="layui-form-label">
                    <span class="x-red">*</span>员工号</label>
                <div class="layui-input-block">
                    <input placeholder="请输入员工号" type="text" id="answers[1]" name="user_account" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="answers[2]" class="layui-form-label">
                    <span class="x-red">*</span>级别</label>
                <div class="layui-input-block">
                    <input placeholder="请输入级别" type="text" id="answers[2]" name="level_name" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="layui-btn" class="layui-form-label"></label>
                <button id="layui-btn" class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
{include file="common/_jQuery"}
<script>
    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //自定义验证规则
            form.verify({
                nikename: function(value) {
                    if (value.length < 5) {
                        return '昵称至少得5个字符啊';
                    }
                },
            });

            //监听提交
            form.on('submit(add)', function(data) {
                $.post('{:url(\'staff_add\')}',data.field,function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:6,time:500},function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg,{icon:5,time:500});
                    }
                });
                return false;
            });
        });
</script>
</body>

</html>